Full-featured liblz4 binding for Rust
About
Rust APIs for the LZ4 compression algorithm.
- Supports almost all liblz4 features
- Zero dependencies except liblz4
- Tested on Windows / macOS / Linux
Usage
Add this to your Cargo.toml
:
[]
= "1.0.3"
Features
- LZ4
- Compression (Block / Streaming)
- Decompression (Block / Streaming)
- Partial Decompression
- Custom Dictionary
- LZ4_HC
- Compression (Block / Streaming)
- Partial Compression
- Custom Dictionary
- LZ4F
- Compression
- Decompression
- Custom Dictionary
- Streaming I/O (
Read
/BufRead
/Write
)
Examples
Block Mode
use ;
let data = b"The quick brown fox jumps over the lazy dog.";
// LZ4 compression
let mut comp = Vec new;
compress_to_vec?;
// LZ4_HC compression
let mut comp = Vec new;
compress_to_vec?;
// LZ4/LZ4_HC decompression
let mut decomp = vec!;
decompress?;
// LZ4F compression
let prefs = default;
let mut comp = Vec new;
compress_to_vec?;
// LZ4F decompression
let mut decomp = Vec new;
decompress_to_vec?;
Streaming Mode
use ;
let data = b"The quick brown fox jumps over the lazy dog.";
// LZ4 compression
let mut comp = new?;
let mut buf = Vec new;
comp.next_to_vec?;
// LZ4_HC compression
let mut comp = new?;
let mut buf = Vec new;
comp.next_to_vec?;
// LZ4/LZ4_HC decompression
let mut decomp = new?;
let result = decomp.next?;
use ;
use ;
// LZ4F Write-based compression
let mut f = create?;
let mut w = new?;
w.write_all?;
// LZ4F Read-based decompression
let mut f = open?;
let mut r = new?;
let mut buf = Vec new;
r.read_to_end?;